import defaultImg from '../../assets/image/default.png'
const user = {
    state: {
        currentUserProfile: {},
        isLogin: true,
        isSDKReady: false, // TIM SDK 是否 ready
        userID: 0,
        userSig: '',
        sdkAppID: 0,
        errorImg: 'this.src="' + require('../../assets/image/default.png') + '"', //加载图片报错时处理方法
        userInfo: {
            nickName: '',
            avatar: '',
            defaultImg: defaultImg
        },
    },
    mutations: {
        updateCurrentUserProfile(state, userProfile) {
            state.currentUserProfile = userProfile
        },
        toggleIsLogin(state, isLogin) {
            state.isLogin = typeof isLogin === 'undefined' ? !state.isLogin : isLogin
        },
        toggleIsSDKReady(state, isSDKReady) {
            state.isSDKReady = typeof isSDKReady === 'undefined' ? !state.isSDKReady : isSDKReady
        },
        reset(state) {
            Object.assign(state, {
                currentUserProfile: {},
                isLogin: false, // 是否显示登录
                isSDKReady: false // TIM SDK 是否 ready
            })
        },
        GET_USER_INFO(state, payload) {
            state.userID = payload.userID
            state.userSig = payload.userSig
            state.sdkAppID = payload.sdkAppID
        },
    },
    actions: {

    }
}

export default user